import { observable, action, toJS } from 'mobx';
import {WeaLocaleProvider} from 'ecCom';
import * as TaskReport from '../../apis/task/taskReport'
const getLabel = WeaLocaleProvider.getLabel;

export default class TaskBaseStore {
    @observable loading =false;
    @observable fbdeltime = 0; //反馈删除时间
    @observable isdel = 0;//责任人是否删除
    @observable docArray = [];
    @observable canedit = false;
    isshow = false;

    @action
    getTaskBase = (params) => {
        this.loading = true;
        TaskReport.getTaskBase(params).then(action(res => {
            if(res.status==1){
                this.isshow = true;
                this.isdel = res.isdel;
                this.fbdeltime = res.fbdeltime;
                this.docArray = [{id:res.docsecid,name:res.docpath}];
                this.canedit = res.canedit;
            }
            this.loading = false;
        }))
    }
    @action
    saveTaskBase = (params) =>{//保存
        this.loading = true;
        params.isdel = this.isdel;
        params.fbdeltime = this.fbdeltime;
        params.operation = "save";
        if(this.docArray && this.docArray.length>0){
            params.docsecid = this.docArray[0].id;
        }
        TaskReport.getTaskBase(params).then(action(res => {
            params.doback(res.status);
            this.loading = false;
        }))
    }
}